<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ page import="com.lukebang.util.RSAUtils"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.security.interfaces.*"%>
<c:set var="ctxPath" value="${pageContext.request.contextPath}"
	scope="application" />
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="description" content="">
<meta name="author" content="ThemeBucket">
<link rel="shortcut icon" type="../image/png">
<title>未付款订单</title>
<link rel="stylesheet"
	href="${ctxPath}/static/js/data-tables/DT_bootstrap.css" />
<link rel="stylesheet" type="text/css"
	href="${ctxPath}/static/js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
<link href="${ctxPath}/static/css/style.css" rel="stylesheet">
<link href="${ctxPath}/static/css/style-responsive.css" rel="stylesheet">
<link rel="shortcut icon" type="image/x-icon"
	href="${ctxPath }/static/images/lukebang320.ico" media="screen" />
<link rel="icon" href="${ctxPath }/static/images/lukebang320.ico"
	type="image/x-icon" />
<link rel="bookmark" href="${ctxPath }/static/images/lukebang320.ico"
	type="image/x-icon" />
<%
	HashMap<String, Object> map = RSAUtils.getKeys();
	//生成公钥和私钥    
	RSAPublicKey publicKey = (RSAPublicKey) map.get("public");
	RSAPrivateKey privateKey = (RSAPrivateKey) map.get("private");
	session.setAttribute("privateKey", privateKey);//私钥保存在session中，用于解密  
	//公钥信息保存在页面，用于加密  
	String publicKeyExponent = publicKey.getPublicExponent().toString(16); //公钥指数   
	String publicKeyModulus = publicKey.getModulus().toString(16); //模    
	request.setAttribute("publicKeyExponent", publicKeyExponent);
	request.setAttribute("publicKeyModulus", publicKeyModulus);
%>
</head>
<body class="sticky-header"
	onload="indexmenu('${oneMenu}','${twoMenu}');">
	<%@ include file="../index/index.jsp"%>
	<div class="main-content" style="overflow-y: auto">
		<!-- 地址栏-->
		<div class="page-heading">
			<h3>鹿客帮下单版</h3>
			<ul class="breadcrumb">
				<li><a>我的订单</a></li>
				<li class="active">安装订单</li>
			</ul>
		</div>
		<!--这里是写一些内容的  -->
		<section class="panel">
			<header class="panel-heading custom-tab turquoise-tab">
				<ul class="nav nav-tabs">
					<li class="active"><a onclick="clickOrders(1,'pay')">未付款</a></li>
					<li class=""><a onclick="clickOrders(1,'taking')">等待工人接单</a></li>
					<li class=""><a onclick="clickOrders(1,'order')">工人已接单</a></li>
					<li class=""><a onclick="clickOrders(1,'move')">工人已出发</a></li>
					<li class=""><a onclick="clickOrders(1,'done')">已完成</a></li>
				</ul>
			</header>
			<div class="panel-body">
				<div class="panel panel-default" style="border-bottom-width: 0px">
					<div class="panel-heading">查询条件</div>
					<form id="queryConditionForm">
						<table
							class="table table-striped table-bordered table-hover table-checkable"
							style="border-width: 0" id="datatable_ajax">
							<thead>
								<tr role="row" class="heading">
									<th align="center" width="5%">订单ID</th>
									<th width="8%">顾客姓名</th>
									<th width="8%">顾客手机号</th>
									<th width="15%">预约时间</th>
									<th width="15%">下单日期</th>
									<th width="5%">操作</th>
								</tr>
								<tr role="row" class="filter">
									<td><input type="text"
										class="form-control form-filter input-sm" name="indentID">
									</td>
									<td><input type="text"
										class="form-control form-filter input-sm" name="cuName"
										placeholder="顾客姓名"></td>
									<td>
										<div style="margin-bottom: 5px">
											<input type="text"
												class="form-control form-filter input-sm margin-bottom-5 clearfix"
												name="cuPhone" placeholder="顾客手机号" />
										</div>
									</td>
									<td>
										<div class="input-group date form_datetime"
											style="margin-bottom: 5px" data-link-field="">
											<input class="form-control" size="16" type="text" value=""
												name="subscribeTimeBegin" placeholder="起始时间" readonly>
											<span class="input-group-addon"><span
												class="glyphicon glyphicon-remove"></span></span> <span
												class="input-group-addon"><span
												class="glyphicon glyphicon-calendar"></span></span>
										</div> <input type="hidden" id="" value="" />
										<div class="input-group date form_datetime"
											style="margin-bottom: 5px">
											<input class="form-control" size="16" type="text" value=""
												name="subscribeTimeEnd" placeholder="结束时间" readonly>
											<span class="input-group-addon"><span
												class="glyphicon glyphicon-remove"></span></span> <span
												class="input-group-addon"><span
												class="glyphicon glyphicon-calendar"></span></span>
										</div> <input type="hidden" value="" />
									</td>
									<td><div class="input-group date form_datetime"
											style="margin-bottom: 5px">
											<input class="form-control" size="16" type="text" value=""
												name="beginTimeBegin" placeholder="起始时间" readonly> <span
												class="input-group-addon"><span
												class="glyphicon glyphicon-remove"></span></span> <span
												class="input-group-addon"><span
												class="glyphicon glyphicon-calendar"></span></span>
										</div> <input type="hidden" id="dtp_input1" value="" />
										<div class="input-group date form_datetime"
											style="margin-bottom: 5px">
											<input class="form-control" size="16" type="text" value=""
												name="beginTimeEnd" placeholder="结束时间" readonly> <span
												class="input-group-addon"><span
												class="glyphicon glyphicon-remove"></span></span> <span
												class="input-group-addon"><span
												class="glyphicon glyphicon-calendar"></span></span>
										</div></td>
									<td>
										<div style="margin-bottom: 5px">
											<button style="width: 70px" id="button_refreshQuery"
												type="button"
												class="btn btn-sm green btn-outline filter-submit margin-bottom">
												<i class="fa fa-search"></i> 查询
											</button>
										</div>
										<button style="width: 70px" type="button"
											onclick="$('#queryConditionForm')[0].reset()"
											class="btn btn-sm red btn-outline filter-cancel">
											<i class="fa fa-times"></i> 重置
										</button>
									</td>
								</tr>
							</thead>
						</table>
					</form>
				</div>
				<div class="tab-content">
					<div id="noPayOrders" class="tab-pane active">
						<table id="tb_installIndent"></table>
					</div>
				</div>
			</div>
		</section>
	</div>
	<!-- 商品信息 -->
	<jsp:include page="sample.jsp">
		<jsp:param value="1" name="install" />
	</jsp:include>

	<div class="modal fade" style="top: 30px;" id="addCurtainModal"
		data-backdrop='static' data-keyboard='false' tabindex="-1"
		role="dialog" aria-labelledby="addCurtainModaLabel" aria-hidden="true">
		<input type="hidden" name="indentID" id="indentID">
		<div class="modal-dialog" style="width: 50%">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-hidden="true">&times;</button>
					<h4 class="modal-title" id="addCurtainModaLabel">添加订单的详细</h4>
				</div>
				<div class="modal-body">
					<form class=" form-horizontal left-align form-well"
						enctype="multipart/form-data" id="goodDetailForm">
						<div class="form-group" id="curtainTypeDiv">
							<label class="col-md-2 col-sm-2 control-label">类型：</label>
							<div class="clearfix">
								<div class="btn-group" style="margin-top: 6px">
									<label><input type="radio" class="toggle"
										onchange="changeCurtainType(this)" value="0" name="type">
										布艺窗帘&nbsp;&nbsp; </label><label><input type="radio" value="1"
										onchange="changeCurtainType(this)" class="toggle" name="type">
										成品窗帘</label>
								</div>
							</div>
						</div>
						<!-- 布艺帘基本信息选择框开始   包括结构款式安装情况  ==================================================-->
						<div id="basicClothCurtainOptionDIV" style="display: none">
							<div class="form-group">
								<label class="col-md-2 col-sm-2 control-label">结构：</label>
								<div class="clearfix">
									<div class="btn-group" style="margin-top: 6px">
										<label><input type="radio" class="toggle"
											onchange="changeClothCurtainStructure(this)" value="0"
											name="structure"> 单层布&nbsp;&nbsp;</label> <label><input
											type="radio" onchange="changeClothCurtainStructure(this)"
											value="1" class="toggle" name="structure">
											单层纱&nbsp;&nbsp; </label><label><input type="radio" value="2"
											class="toggle" onchange="changeClothCurtainStructure(this)"
											name="structure"> 布纱双层</label>
									</div>
								</div>
							</div>
							<div class="form-group" id="">
								<label class="col-md-2 col-sm-2 control-label">款式：</label>
								<div class="clearfix">
									<div class="btn-group" style="margin-top: 6px">
										<label><input type="radio" class="toggle" value="0"
											onchange="changeClothCurtainStyle(this)" name="style">
											打孔款&nbsp;&nbsp; </label><label><input type="radio" value="3"
											class="toggle" onchange="changeClothCurtainStyle(this)"
											name="style"> 韩款或者挂钩款&nbsp;&nbsp; </label><label><input
											type="radio" value="4" class="toggle"
											onchange="changeClothCurtainStyle(this)" name="style">
											帘头款</label>
									</div>
								</div>
							</div>
							<div class="form-group" id="intallClothCurtainSituatonDIV"
								style="display: none">
								<label class="col-md-2 col-sm-2 control-label">安装情况：</label>
								<div class="clearfix">
									<div class="btn-group" style="margin-top: 6px">
										<label><input type="radio" class="toggle"
											onchange="changeClothCurtainInstallSituation(this)" checked
											value="1" name="installCase"> 布纱位置相同&nbsp;&nbsp; </label><label><input
											type="radio" value="0" class="toggle" name="installCase"
											onchange="changeClothCurtainInstallSituation(this)">
											布纱位置不同</label>
									</div>
								</div>
							</div>
						</div>
						<!-- 布艺帘基本信息选择框结束   包括结构款式安装情况 ================================================== -->
						<!-- 添加尺寸按钮显示开始    添加按钮尺寸开始 -->
						<div id="button_addSizeDIV">
							<div class="form-group">
								<label class="col-md-2 col-sm-2 control-label">添加尺寸：</label>
								<div class="clearfix button-size-custom" id="button_addSize_1">
									<div class="btn-group" style="margin-top: 6px">
										<button type="button" onclick="click_addProductCurtainSize()"
											class="btn btn-xs btn-danger custom-addProductSize-button">添加成品帘尺寸[未填]</button>
									</div>
								</div>
								<div class="clearfix button-size-custom" id="button_addSize_2">
									<div class="btn-group" style="margin-top: 6px">
										<button type="button"
											class="btn btn-xs btn-danger custom-addYarnSize-button"
											onclick="click_addClothCurtainYarnSize()">添加纱帘尺寸[未填]</button>
									</div>
								</div>
								<div class="clearfix button-size-custom" id="button_addSize_3">
									<div class="btn-group" style="margin-top: 6px">
										<button type="button"
											class="btn btn-xs btn-danger custom-addClothSize-button"
											onclick="click_addClothCurtainClothSize()">添加布帘尺寸[未填]</button>
									</div>
								</div>
								<div class="clearfix button-size-custom" id="button_addSize_4">
									<div class="btn-group" style="margin-top: 6px">
										<button type="button"
											class="btn btn-xs btn-danger custom-addYarnSize-button"
											onclick="click_addClothCurtainYarnSize()">添加纱帘尺寸[未填]</button>
									</div>
									<div class="btn-group" style="margin-top: 6px">
										<button type="button"
											class="btn btn-xs btn-danger custom-addHeadSize-button"
											onclick="click_addClothCurtainHeadShadeSize()">添加帘头尺寸[未填]</button>
									</div>
								</div>
								<div class="clearfix button-size-custom" id="button_addSize_5">
									<div class="btn-group" style="margin-top: 6px">
										<button type="button"
											class="btn btn-xs btn-danger custom-addClothSize-button"
											onclick="click_addClothCurtainClothSize()">添加布帘尺寸[未填]</button>
									</div>
									<div class="btn-group" style="margin-top: 6px">
										<button type="button"
											onclick="click_addClothCurtainHeadShadeSize()"
											class="btn btn-xs btn-danger custom-addHeadSize-button">添加帘头尺寸[未填]</button>
									</div>
								</div>
								<div class="clearfix button-size-custom" id="button_addSize_6">
									<div class="btn-group" style="margin-top: 6px">
										<button type="button"
											class="btn btn-xs btn-danger custom-addClothSize-button"
											onclick="click_addClothCurtainClothSize()"
											style="margin-right: 10px">添加布帘尺寸[未填]</button>
										&nbsp;&nbsp;
										<button type="button"
											class="btn btn-xs btn-danger custom-addHeadSize-button"
											style="margin-right: 10px"
											onclick="click_addClothCurtainHeadShadeSize()">添加帘头尺寸[未填]</button>
										&nbsp;&nbsp;
									</div>
								</div>
								<div class="clearfix button-size-custom" id="button_addSize_7">
									<div class="btn-group" style="margin-top: 6px">
										<button type="button"
											class="btn btn-xs btn-danger custom-addClothSize-button"
											style="margin-right: 10px"
											onclick="click_addClothCurtainClothSize()">添加布帘尺寸[未填]</button>
										&nbsp;&nbsp;
									</div>
								</div>
								<div class="clearfix button-size-custom" id="button_addSize_8">
									<div class="btn-group" style="margin-top: 6px">
										<button type="button"
											class="btn btn-xs btn-danger custom-addClothSize-button"
											style="margin-right: 10px"
											onclick="click_addClothCurtainClothSize()">添加布帘尺寸[未填]</button>
										&nbsp;&nbsp;
										<button type="button"
											class="btn btn-xs btn-danger custom-addYarnSize-button"
											style="margin-right: 10px"
											onclick="click_addClothCurtainYarnSize()">添加纱帘尺寸[未填]</button>
										&nbsp;&nbsp;
										<button type="button"
											class="btn btn-xs btn-danger custom-addHeadSize-button"
											style="margin-right: 10px"
											onclick="click_addClothCurtainHeadShadeSize()">添加帘头尺寸[未填]</button>
										&nbsp;&nbsp;
									</div>
								</div>
								<div class="clearfix button-size-custom" id="button_addSize_9">
									<div class="btn-group" style="margin-top: 6px">
										<button type="button"
											class="btn btn-xs btn-danger custom-addClothSize-button"
											style="margin-right: 10px"
											onclick="click_addClothCurtainClothSize()">添加布帘尺寸[未填]</button>
										&nbsp;&nbsp;
										<button type="button"
											class="btn btn-xs btn-danger custom-addYarnSize-button"
											style="margin-right: 10px"
											onclick="click_addClothCurtainYarnSize()">添加纱帘尺寸[未填]</button>
										&nbsp;&nbsp;
									</div>
								</div>
							</div>
						</div>
						<!-- 添加尺寸按钮显示结束    添加尺寸按钮结束 -->
					</form>
					<div id="kv-avatar-errors-1" class="center-block"
						style="width: 800px; display: none"></div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-info"
						onclick="addGoodForIndent2_click(this)">保存</button>
					<button type="button" class="btn btn-default"
						onclick="javascript:closeGoodDetailChooseForm()"
						data-dismiss="modal">关闭</button>
				</div>
			</div>
		</div>
	</div>

	<!-- 商家信息 -->
	<jsp:include page="merchantInfo.jsp"></jsp:include>
	<!-- 配件信息 -->
	<jsp:include page="assestype.jsp"></jsp:include>
	<!-- 取货信息 -->
	<jsp:include page="pickup.jsp"></jsp:include>
	<!-- 支付订单 -->
	<jsp:include page="payMoney.jsp">
		<jsp:param value="1" name="type" />
	</jsp:include>
	<!-- 输入密码 -->
	<jsp:include page="password.jsp"></jsp:include>
	<!-- 成品帘 -->
	<jsp:include page="../newTask/finishMap.jsp"></jsp:include>
	<!-- 布艺帘  布 -->
	<jsp:include page="../newTask/cloth.jsp"></jsp:include>
	<!-- 布艺帘  纱 -->
	<jsp:include page="../newTask/yarn.jsp"></jsp:include>
	<!-- 布艺帘 帘头 -->
	<jsp:include page="../newTask/head.jsp"></jsp:include>
</body>
<!--pickers initialization-->
<script type="text/javascript">
	var costRules = new Object;
	var indentPrice = new Number(0);
	var isNeedTakingGoods = new Number(0);
	var realIndentPrice = new Number(0);
	
	var TableInit = function() {
		var oTableInit = new Object();
		//初始化Table
		oTableInit.Init = function() {
			$('#tb_installIndent').bootstrapTable(
							{
								url : '${ctxPath}/indent/queryInstallIndentByMerchant', //请求后台的URL（*）
								method : 'post', //请求方式（*）
								toolbar : '#toolbar', //工具按钮用哪个容器
								striped : true, //是否显示行间隔色
								cache : false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
								pagination : true, //是否显示分页（*）
								sortable : false, //是否启用排序
								sortName : 'beginTime',
								sortOrder : "desc", //排序方式
								queryParams : oTableInit.queryParams,//传递参数（*）
								sidePagination : "server", //分页方式：client客户端分页，server服务端分页（*）
								pageNumber : 1, //初始化加载第一页，默认第一页
								pageSize : 8, //每页的记录行数（*）
								pageList : [ 8, 25, 50, 100 ],
								search : false, //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
								strictSearch : false,
								showColumns : false, //是否显示所有的列
								showRefresh : true, //是否显示刷新按钮
								minimumCountColumns : 2, //最少允许的列数
								clickToSelect : false, //是否启用点击选中行
								height : 600, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
								uniqueId : "indentId", //每一行的唯一标识，一般为主键列
								showToggle : true, //是否显示详细视图和列表视图的切换按钮
								cardView : false, //是否显示详细视图
								detailView : false, //是否显示父子表
								contentType : 'application/x-www-form-urlencoded; charset=UTF-8',
								columns : [
										{
											field : 'indentId',
											title : '订单ID',
											width : '3%',
											align : "center"
										},
										{
											field : 'beginTime',
											title : '下单时间',
											width : '11%',
											align : "center"
										},
										{
											field : 'subscribeTime',
											title : '预约时间',
											width : '11%',
											align : "center"
										},
										{
											field : 'merchantsPrice',
											title : '付款钱数',
											width : '10%',
											align : "center",
											formatter : function(value, row,
													index) {
												return value;
											}
										},
										{
											field : 'remark',
											title : '订单备注',
											width : '20%',
											align : "center"
										},
										{
											field : 'customerAddress',
											title : '顾客姓名',
											width : '8%',
											align : "center",
											formatter : function(value, row,
													index) {
												if (value)
													return value.name;
											}
										},
										{
											field : 'tag',
											title : '顾客详细信息',
											width : '10%',
											align : "center",
											formatter : function(value, row,
													index) {

												return "<button class='btn btn-success btn-xs' onclick='javascript:viewCustomerDetialModalOpen("
														+ row.indentId
														+ ")'>查看顾客信息</button>";
											}
										},
										{
											field : 'isNeedTakeGoods',
											title : '查看取货信息',
											width : '10%',
											align : "center",
											formatter : function(value, row,
													index) {
												if (value == 0) {
													return "<font color='red'>未选择</font>";
												} else {
													return "<button class='btn btn-success btn-xs' onclick='javascript:viewPickupInfoModalOpen("
															+ row.indentId
															+ ")'>查看取货信息</button>";
												}
											}
										},
										{
											field : 'indentId',
											title : '查询商品信息',
											width : '10%',
											align : "center",
											formatter : function(value, row,
													index) {
												return "<button class='btn btn-success btn-xs' onclick='javascript:viewGoodDetailModalOpen("
														+ value
														+ ")'>查看商品信息</button>";
											}
										},
										{
											field : 'tag2',
											title : '付款',
											width : '10%',
											align : "center",
											formatter : function(value, row,
													index) {
												return "<button class='btn btn-success btn-xs'  onclick='javascript:payIndentModalOpen("
														+ row.indentId
														+ ","
														+ row.merchantsRealPrice
														+ ")'>付款</button>";
											}
										},
										{
											field : 'tag2',
											title : '取消订单',
											width : '10%',
											align : "center",
											formatter : function(value, row,
													index) {
												return "<button class='btn btn-success btn-xs'  onclick='javascript:quitIndentModalOpen("
														+ row.indentId
														+ ",1,"
														+ row.customerId
														+ ")'>取消</button>";
											}
										}, ]
							});
		};

		//得到查询的参数
		oTableInit.queryParams = function(params) {
			var temp = { //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
				limit : params.limit, //页面大小
				offset : params.offset, //页码
				order : params.order,
				sort : params.sort,
				indentID : $("input[name='indentID']").val(),
				subscribeTimeBegin : $("input[name='subscribeTimeBegin']").val(),
				subscribeTimeEnd : $("input[name='subscribeTimeEnd']").val(),
				beginTimeBegin : $("input[name='beginTimeBegin']").val(),
				beginTimeEnd : $("input[name='beginTimeEnd']").val(),
				cuName : $("input[name='cuName']").val(),
				cuPhone : $("input[name='cuPhone']").val(),
				indentStatus : 4,
			};
			return temp;
		};
		return oTableInit;
	};

	$(function() {
		$("input[name='addPrice']").TouchSpin({
			min : 0,
			max : 1000,
			//step : 5,
			boostat : 5,
			maxboostedstep : 10,
			postfix : '元'
		});
		$(".input_accText").TouchSpin({
			min : 0,
			max : 100,
			step : 1,
			boostat : 5,
			maxboostedstep : 10,
		});
		//1.初始化Table
		var oTable = new TableInit();
		oTable.Init();
		$('.form_datetime').datetimepicker({
			language : 'zh-CN',
			format : "yyyy-mm-dd hh:ii:ss",
			weekStart : 1,
			todayBtn : 1,
			autoclose : 1,
			todayHighlight : 1,
			startView : 2,
			forceParse : 0,
			showMeridian : 1
		});
		$('.form_date').datetimepicker({
			//language : 'fr',
			weekStart : 1,
			todayBtn : 1,
			autoclose : 1,
			todayHighlight : 1,
			startView : 2,
			minView : 2,
			forceParse : 0
		});
		$('.form_time').datetimepicker({
			//language : 'fr',
			weekStart : 1,
			todayBtn : 1,
			autoclose : 1,
			todayHighlight : 1,
			startView : 1,
			minView : 0,
			maxView : 1,
			forceParse : 0
		});
		$("#button_refreshQuery").click(function() {
			var opt = {
				pageNumber : 1,
				query : {
					offset : 0
				}
			};
			//从新开始计数
			$("#tb_installIndent").bootstrapTable('refresh', opt);
		});
		loadInstallIndentGoodDetailTable();
	});
	
	
	//查看那个订单的那个用户
	function viewCustomerDetialModalOpen(id) {
		var viewRow = $('#tb_installIndent').bootstrapTable('getRowByUniqueId',
				id);
		$("#viewCustomerDetialModal #txt_customerName").val(
				viewRow.customerAddress.name);
		$("#txt_customerPhoneNumber").val(viewRow.customerAddress.phone);
		$("#txt_customerAddress").val(viewRow.customerAddress.customerAddress);
		$("#txt_customerRemark").val(viewRow.remark);
		$('#viewCustomerDetialModal').modal('show');
	}
	//悬赏
	function payIndentModalOpen(indentId, realPrice) {
		$.post("${ctxPath}/cityCostRule/queryCostRuleByIndent", {
			indentID : indentId
		}, function(_costRules) {
			costRules = _costRules;
			var viewRow = $('#tb_installIndent').bootstrapTable(
					'getRowByUniqueId', indentId);
			$("#txt_crampetPrice").html(
					"壁钩安装费" + _costRules.crampetPrice + "元/对");
			$("#txt_fourClawPrice").html(
					"四抓钩安装费" + _costRules.fourClawPrice + "元/套");
			$("#txt_motorPrice").html("电机安装费" + _costRules.motorPrice + "元/台");
			indentPrice = parseInt(viewRow.merchantsPrice);
			isNeedTakingGoods = parseInt(viewRow.isNeedTakeGoods);
			realIndentPrice = viewRow.goodPrice;
			$("#payIndentForm #totalPrice").val(indentPrice + 5);
			$("#payIndentForm #indentID").val(indentId);
			realIndentPrice = realPrice;
			$("#payIndentModal").modal('show');
		});
	}
	/*
	function payMeasureIndentFire() {
		$("#payInstallIndentForm").submit();
	}*/
	function viewInstallPartsModalOpen(id) {
		var viewRow = $('#tb_installIndent').bootstrapTable('getRowByUniqueId',
				id);
		$("#txt_repairPartsMotorNum").val(viewRow.motorNum);
		$("#txt_repairPartsSizhuagouNum").val(viewRow.sizhuagouNum);
		$("#txt_repairPartsBigouNum").val(viewRow.bigouNum);
		$('#viewInstallPartsModal').modal('show');
	}
	function viewPickupInfoModalOpen(id) {
		var viewRow = $('#tb_installIndent').bootstrapTable('getRowByUniqueId',
				id);
		$("#txt_pickupPhone").val(viewRow.takeGoodsTel);
		$("#txt_pickupBaseAddress").val(viewRow.baseAddress);
		$("#txt_pickupDetailAddress").val(viewRow.detailAddress);
		$('#viewPickupInfoModal').modal('show');
	}
	//打开浏览安装订单的商品modal
	function viewGoodDetailModalOpen(indentID) {
		$(".toSecondModal").attr("id", indentID);
		$.post('${ctxPath}/good/queryInstallIndentGood', {
			indentID : indentID
		}, function(data) {
			//console.log(data);
			$('#indentGoodDetailTable').bootstrapTable('load',
					data.installIndentGoods);
			var beginNum = 0;
			$.each(data.collapseNumbers, function(index, valueChild) {
				$('#indentGoodDetailTable').bootstrapTable('mergeCells', {
					index : beginNum,
					field : 'type_script',
					rowspan : valueChild,
				});
				beginNum = beginNum + valueChild;
			})
			$("#viewIndentGoodDetailModal").modal('show');
		});
	}
	function refreshInstallIndentGoods() {
		$('#indentGoods_Table').bootstrapTable('load', data.goodPart);
		var beginNum = 0;
		$.each(data.collapseNumbers, function(index, valueChild) {
			$('#indentGoods_Table').bootstrapTable('mergeCells', {
				index : beginNum,
				field : 'type_script',
				rowspan : valueChild,
			});
			beginNum = beginNum + valueChild;
		})
	}

	// 计算订单的总价格
	function countTotalIndentPrice() {
		if (typeof costRules.crampetPrice != "undefined") {
			var totalIndentPrice = new Number(0);
			// 选择数量的价钱
			var crampetNumber = $("#payIndentForm input[name='crampetNumber']")
					.val();
			var fourClawNumber = $(
					"#payIndentForm input[name='fourClawNumber']").val();
			var motorNumber = $("#payIndentForm input[name='motorNumber']")
					.val();
			var accPrice = parseInt(crampetNumber)
					* parseInt(costRules.crampetPrice);
			accPrice = accPrice + parseInt(fourClawNumber)
					* parseInt(costRules.fourClawPrice);
			accPrice = accPrice + parseInt(motorNumber)
					* parseInt(costRules.motorPrice);
			totalIndentPrice = totalIndentPrice + accPrice;
			if ((realIndentPrice + accPrice) > costRules.installStartingFare) {
				totalIndentPrice = realIndentPrice + accPrice;
			} else {
				totalIndentPrice = costRules.installStartingFare;
			}
			if (isNeedTakingGoods == 1) {
				totalIndentPrice = totalIndentPrice
						+ parseInt(costRules.takeGoodsPrice);
			}
			totalIndentPrice = totalIndentPrice
					+ parseInt($("#payIndentForm input[name='addPrice']").val());
			if ($("#payIndentForm input[name='relievedBao']:checked").val() == 1) {
				totalIndentPrice = totalIndentPrice + 5;
			}
			$("#payIndentForm #totalPrice").val(totalIndentPrice);
		}
	}
	function loadInstallIndentGoodDetailTable() {
		$('#indentGoodDetailTable')
				.bootstrapTable(
						{
							toolbar : '#toolbar', // 工具按钮用哪个容器
							height : 500,
							columns : [
									{
										field : 'type_script',
										title : '安装基本信息',
										align : "center",
										width : "10%",
										formatter : function(value, row, index) {

											var curtainTypeStr = !row.good.curtainTypeStr ? "无"
													: row.good.curtainTypeStr;
											var basic = "品种  :"
													+ curtainTypeStr
													+ "<br/>"
													+ "<a href='javascript:deleteGoods("
													+ row.good.goodsId
													+ ")' class='deleteGoodID'>删除商品</a>";
											return basic;

										}
									},
									{
										field : 'good',
										title : '安装信息',
										align : "center",
										width : "15%",
										formatter : function(value, row, index) {
											var info;
											var installCase = value.installCase == 1 ? "<br/>布纱安装位置：相同"
													: "";
											var structureStr = !value.structureStr ? "无"
													: value.structureStr;
											var styleStr = !value.styleStr ? "无"
													: value.styleStr;
											var goodSpecialTypeStr = !value.goodSpecialTypeStr ? "无"
													: value.goodSpecialTypeStr;
											if (value.type == 0) {

												info = "结构：" + structureStr
														+ "<br/>款式：" + styleStr
														+ "<br/>类型："
														+ goodSpecialTypeStr
														+ installCase;
											} else {
												info = "类型："
														+ goodSpecialTypeStr;

											}
											return info;
										}
									},
									{
										field : 'type',
										title : '款式信息',
										align : "left",
										width : "23%",
										formatter : function(value, row, index) {

											var kuashi = "";
											var accessoriesType = !row.accessoriesType ? "无"
													: row.accessoriesType;
											var pinstallSite = !row.pinstallSite ? "无"
													: row.pinstallSite;
											var accStr = !row.acc ? "无装饰头"
													: row.acc;
											var panzhuangfangshi = !row.panzhuangfangshi ? "无"
													: row.panzhuangfangshi;
											// 如果是布尺寸或者纱尺寸
											if (value == 0 || value == 1) {
												kuashi = "布帘配件："
														+ accessoriesType + "，"
														+ accStr + "<br/>安装方式："
														+ pinstallSite
														+ "<br/>安装配件："
														+ panzhuangfangshi;
											}
											// 如果是帘头
											else if (value == 2) {
												kuashi = "帘头安装情况："
														+ pinstallSite

														+ "<br/>帘头配件："
														+ accessoriesType;
											}
											// 如果是成品帘
											else {
												kuashi = "无";
											}
											return kuashi;
										}
									},
									{
										field : 'type',
										title : '尺寸信息',
										align : "center",
										width : "200px",
										formatter : function(value, row, index) {
											// 如果是布尺寸或者纱尺寸
											var size;
											var width = !row.wide ? "0"
													: row.wide;
											var high = !row.high ? "0"
													: row.high;
											var saleNumber = !row.saleNumber ? "0"
													: row.saleNumber;
											if (value == 0 || value == 1) {

												size = "宽：" + width + "（米），高："
														+ high

														+ "（米）" + "<br/>杆长："
														+ saleNumber + "（米）";
											}
											// 如果是帘头
											else if (value == 2) {

												size = "宽：" + width

												+ "（米），配件长度：" + saleNumber;
											}
											// 如果是成品帘
											else {

												size = "宽：" + width + "（米），高："
														+ high

														+ "（米）";
											}
											return size;
										}
									}, {
										field : 'remark',
										title : '备注',
										width : "15%",
										align : "center"
									} ]
						});
	}
	// 预览订单的价格
	$("#payIndentForm input").change(function() {
		countTotalIndentPrice();
	});

	/* function addGds(node){
		var indentID=$("#" + node).val();
		$('#addCurtainModal').modal('show');
		
	} */
	//删除商品后重新计算价格 关闭模态框时出发事件。
	$(function() {
		$('#viewIndentGoodDetailModal').on('hide.bs.modal', function() {
			//删除商品后重新计算价格
			var indentID = $(".toSecondModal").attr("id");
			//alert("indentID=" + indentID);
			$.ajax({
				url : '${ctxPath }/indent/resetCalculateIndent',
				type : 'post',
				dataType : 'JSON',
				data : {
					indentID : indentID,
				},
				success : function(data) {
					$("button[name='refresh']").trigger("click");
				}
			});
		})
	});
</script>

<!--加密与java客户端解密  -->
<script type="text/javascript"
 	src="${ctxPath}/static/js/security/security.js"></script>
 <!-- 日期插件 -->
<script type="text/javascript"
 	src="${ctxPath}/static/js/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript"
	src="${ctxPath}/static/js/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript"
	src="${ctxPath}/static/js/orders/public.js"></script>
<script type="text/javascript"
	src="${ctxPath}/static/js/taskManage/public.js"></script>
<!-- tables插件的引用 -->
<link href="${ctxPath}/static/js/bootstrap-table/bootstrap-table.css"
	rel="stylesheet" />
<script type="text/javascript"
	 src="${ctxPath}/static/js/bootstrap-table/bootstrap-table.js"></script>
<script type="text/javascript"
	src="${ctxPath}/static/js/bootstrap-table/locale/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript"
	 src="${ctxPath }/static/js/pickers-init.js"></script>
<script type="text/javascript"
	src="${ctxPath}/static/js/custom/taskList/addInstall.js"></script>
<!-- jQuery 输入递增组件。 它支持鼠标滚轮和上/下键。支持前缀、后缀单，最小值、最大值范围输入。 -->
<script type="text/javascript"
	src="${ctxPath }/static/js/bootstrap-touchspin/bootstrap.touchspin.min.js"></script>
<!-- jQuery 验证插件 -->
<script type="text/javascript"
	 src="${ctxPath}/static/js/jquery.validate.min.js"></script>
<!-- jQuery向导插件 -->
<script type="text/javascript"
	 src="${ctxPath}/static/js/jquery.stepy.js"></script>
<!-- 自定义滚动条jQuery插件 -->
<script type="text/javascript"
	src="${ctxPath}/static/js/jquery.nicescroll.js"></script>
</html>
